package com.bluefish.bltuan.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.bluefish.bltuan.dao.MsgDao;
import com.bluefish.bltuan.module.Category;
import com.bluefish.bltuan.module.msg.Message;
import com.bluefish.bltuan.module.msg.MessageType;
import com.bluefish.bltuan.util.PageIndex;

@Repository
public class MsgDaoImpl extends AbstractDaoImpl<Message, Integer> implements MsgDao{

	private static final String CITY = "city";

	/**
	 * 
	 */
	private static final long serialVersionUID = 1099708233311323373L;

	private static final String TYPE = "type";

	public int countByType(MessageType type) {
		return countByProperty(TYPE, type);
	}

	public List<Message> listByType(MessageType type) {
		return listByProperty(TYPE, type);
	}

	public List<Message> listByType(MessageType type, PageIndex pageIndex) {
		return listByProperty(pageIndex, TYPE, type);
	}

	public List<Message> listByType(MessageType type, int number) {
		return listByPropertyAndSize(number, TYPE, type);
	}
	
	public List<Message> listByTypeAndCity(PageIndex pageIndex,
			MessageType type, Category city) {
		return listByProperties(pageIndex, new String[]{TYPE,CITY}, new Object[]{type, city});
	}

}
